package com.example.graduatetest.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

import com.example.graduatetest.bean.User;

public class Constant {
    //http://www.blueskyhome.work:8080
    //public static String www = "http://7gstfa.natappfree.cc";
    public static String www = "http://www.blueskyhome.work:8080";
    private static String grade;
    private static User user;

    public static String setGradeFun(int number,String format){

        if(format.equals("百分制")){
            if(number < 60){
                grade = "不及格";
            }else if(number < 70){
                grade = "及格";
            }else if(number < 80){
                grade = "良好";
            }else if(number < 90){
                grade = "优秀";
            }else{
                grade = "满绩点";
            }
        }else{
            if(number < 90){
                grade = "不及格";
            }else if(number < 100){
                grade = "及格";
            }else if(number < 120){
                grade = "良好";
            }else if(number < 140){
                grade = "优秀";
            }else{
                grade = "满绩点";
            }
        }
        return grade;
    }

    public static User checkStudentOrTeacher(Activity activity){
        user = new User();
        SharedPreferences preferences = activity.getSharedPreferences("data", Context.MODE_PRIVATE);
        user.setLogin(preferences.getBoolean("isLogin", false));
        user.setName(preferences.getString("name", "默认"));
        user.setPassword(preferences.getString("password", "123456"));
        user.setStudent(preferences.getBoolean("isStudent", true));
        user.setNumber(preferences.getString("number", "2017211973"));
        return user;
    }
}
